﻿@model DingTalkAgent.Web.Models.RolePower
@{
    ViewBag.Title = "RolePower";
    Layout = "~/Views/Shared/_Layout.cshtml";
}

    <div class="wrapper wrapper-content">
        <div class="row animated fadeInRight">
            <div class="col-sm-3">
                <div class="ibox float-e-margins">
                    <div class="ibox-title">
                        <h5>权限结构</h5>
                        <div class="ibox-tools">
                            <a class="collapse-link">
                                <i class="fa fa-chevron-up"></i>
                            </a>
                            <a class="close-link">
                                <i class="fa fa-times"></i>
                            </a>
                        </div>
                    </div>
                    <div class="ibox-content">
                        <div class="tab-content">
                            <div id="tab-1" class="tab-pane active">
                                <div class="full-height-scroll">
                                    <div class="table-responsive">
                                        <table class="table table-hover" id="table_1">
                                            <tbody>
                                             @foreach (var item in @Model.RoleList)
                                             {
                                                <tr>
                                                    <td>
                                                        <a data-toggle="tab" href="#" class="client-link">@item.Name</a>
                                                    </td>
                                                    @Html.Hidden("RoleID" + @item.ID, @item.ID)
                                                </tr>
                                             }
                                            </tbody>
                                        </table>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>

            <div class="col-sm-9">
                <div class="ibox float-e-margins">
                    <div class="ibox-title">
                        <h5>权限设置</h5>
                    </div>
                    <div class="ibox-content">
                        <button class="btn btn-primary" type="button" onclick="Save()">保存</button>
                    </div>
                    @using (Html.BeginForm("RolesPowerX", "Roles"))
                    {
                        @Html.Hidden("RoleID", 0)
                        <div class="ibox-content">
                            <div class="Table_div01" id="RolePower">
                            </div>
                        </div>
                    }
                     </div>
            </div>
        </div>
    </div>

    <script type="text/javascript">

    $(document).ready(function () {

    $("#table_1 tr").click(function (e) {
        var Roles = $(this).find("input").val();
        e.preventDefault();
        $("#table_1 tr").removeClass('active');
        $(this).addClass('active');
        parent.layer.msg('正在提交信息，请等待……', { time: 1500 });
        $("#RoleID").val(Roles);
        $.get("/Roles/Nav_Action", "RoleID=" + Roles + "&time=" + new Date().getTime(), function (data) {
            if (CS00(data)) //超时判断
            {
                //子窗口，要返回父级登录
                parent.window.location.href = "/Account/LogOn";
                return false;
            }
            else {
                $("#RolePower").html(data);
            }
            $(".layui-layer-content").remove();
        })
    });

    $("#table_1 tr").eq(0).click();
    });
    function Save() {
        SetData("/Roles/RolePowerX", '权限分配成功!');
    };
    </script>

